package com.dreamers.core;

import cn.hutool.core.util.ClassUtil;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

public  class MonoBehaviourManager {
    public static MonoBehaviourManager INSTANCE = new MonoBehaviourManager();
    public  static List<MonoBehaviour> monoBehaviourList = new ArrayList<>();


    public void init() {
        Set<Class<?>> classes = ClassUtil.scanPackage("com.dreamers.extend");
        for (Class<?> aClass : classes) {
            try {
                MonoBehaviour o =(MonoBehaviour) aClass.getConstructor().newInstance();
                monoBehaviourList.add(o);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
/*        monoBehaviourList.add(new MapObject());
        monoBehaviourList.add(new MapObject2());*/

        for (MonoBehaviour monoBehaviour : monoBehaviourList) {
            IAwakeListener.iAwakeListenerList.add(monoBehaviour);
            IStartListener.iStartListenerList.add(monoBehaviour);
            IRenderListener.iRenderListenerList.add(monoBehaviour);
            ITickListener.iTickListenerList.add(monoBehaviour);
            IKeyListener.iKeyListenerList.add(monoBehaviour);
            IMouseListener.iMouseListenerList.add(monoBehaviour);
            IMouseWheelListener.iMouseWheelListenerList.add(monoBehaviour);
        }
    }
}
